package com.meetingshow.commu.service;

import java.util.ArrayList;
import java.util.List;

import com.meetingshow.common.base.dao.model.QueryStruct;
import com.meetingshow.common.base.service.BaseServiceImp;
import com.meetingshow.common.base.service.model.QueryResults;
import com.meetingshow.commu.dao.AnswerDAO;
import com.meetingshow.commu.dao.model.AnswerPO;
import com.meetingshow.commu.service.model.AnswerQueryParas;
import com.meetingshow.commu.service.util.AnswerQueryParasBuilder;
import com.meetingshow.commu.service.util.AnswerServiceParas;

public class AnswerServiceImp extends BaseServiceImp implements IAnswerService {

    private AnswerDAO answerDAO;
    
    /**
     * @return the answerDAO
     */
    public AnswerDAO getAnswerDAO() {
        return answerDAO;
    }

    /**
     * @param answerDAO the answerDAO to set
     */
    public void setAnswerDAO(AnswerDAO answerDAO) {
        this.answerDAO = answerDAO;
    }

    @Override
    public Integer saveAnswer(AnswerPO answerPO) throws Exception {
        return getAnswerDAO().saveAnswer(answerPO);
    }

    @Override
    public void updateAnswer(AnswerPO answerPO) throws Exception {
        getAnswerDAO().updateAnswer(answerPO);
    }

    @Override
    public void removeAnswer(AnswerPO answerPO) throws Exception {
        getAnswerDAO().removeAnswer(answerPO);
    }
    
    @Override
    public AnswerPO loadAnswerById(Integer answerId) throws Exception {
        return getAnswerDAO().loadAnswerById(answerId);
    }

    @Override
    public QueryResults<AnswerPO> queryAnswer(
            AnswerQueryParas answerQueryParas) throws Exception {
        QueryStruct queryStruct = new QueryStruct();
        List<String> tableList = new ArrayList<String>();
        List<String> returnObjectList = new ArrayList<String>();
        
        tableList.add(AnswerServiceParas.ANSWER_PO);
        returnObjectList.add(AnswerServiceParas.ANSWER_PO);
        
        queryStruct.setTableList(tableList);
        queryStruct.setReturnObjectList(returnObjectList);
        
        queryStruct = AnswerQueryParasBuilder.answerQueryBuilder(queryStruct, answerQueryParas);
        QueryResults<AnswerPO> queryResults = getAnswerDAO().queryAnswer(queryStruct);
        return queryResults;
    }

}
